home *** CD-ROM | disk | FTP | other *** search
-
- /******************************************************************************
-
- MODULE
- SetOwner.c
-
- DESCRIPTION
- change the Ownership for a file
-
- NOTES
- Kickstart 3.0+ required
- compiles w/ SAS/C v6.51
-
- as is this simple prog is mostly senseless ...
-
- BUGS
- none known
-
- TODO
- we should better add
- * access to an id database instead of simple ownership id
-
- EXAMPLES
-
- SEE ALSO
-
- INDEX
-
- HISTORY
- 26-03-95 b_noll created
-
- AUTHOR
- Bernd Noll, Brunnenstrasse 55, D-67661 Kaiserslautern
- b_noll@informatik.uni-kl.de
-
- ******************************************************************************/
-
- /**************************************
- Includes
- **************************************/
-
- #ifndef EXEC_LIBRARIES_H
- # include <exec/libraries.h>
- #endif /* EXEC_LIBRARIES_H */
-
- #ifndef CLIB_EXEC_PROTOS_H
- # include <clib/exec_protos.h>
- #endif /* CLIB_EXEC_PROTOS_H */
-
- #ifndef DOS_DOS_H
- # include <dos/dos.h>
- #endif /* DOS_DOS_H */
-
- #ifndef CLIB_DOS_PROTOS_H
- # include <clib/dos_protos.h>
- #endif /* CLIB_DOS_PROTOS_H */
-
- #include <proto/dos.h>
- #include <proto/exec.h>
-
- /**************************************
- Defines & Structures
- **************************************/
-
- #ifndef ABSEXECBASE
- #define ABSEXECBASE ((struct ExecBase **)4L)
- #endif
-
- struct _arg {
- /* ******************** USER FORMAT ******************** */
- #define FORMAT "PATH/M/A,OWNERID/N/A"
-
- STRPTR *path;
- ULONG *ownerid;
-
- /* ******************** USER FORMAT ******************** */
- }; /* struct _argv */
-
- #define MAXPATHLEN 256
- #define MAXLINELEN 256
-
- #define VERSIONPREFIX "\0$VER: "
- #define VERSIONOFFSET 0
- #define FORMATPREFIX "\0$ARG: "
- #define FORMATOFFSET 7
-
- /**************************************
- Implementation
- **************************************/
-
- long _main (void)
- {
- const char* version = VERSIONPREFIX "SetOwner 1.0 " __AMIGADATE__ + VERSIONOFFSET;
- long retval = RETURN_FAIL;
- struct ExecBase*SysBase = *ABSEXECBASE;
- struct Library* DOSBase;
-
- if (DOSBase = OpenLibrary (DOSNAME, 37)) {
- struct _arg argv = { 0 };
- APTR args;
- retval = RETURN_ERROR;
- if (args = (void*)ReadArgs(FORMATPREFIX FORMAT + FORMATOFFSET, (LONG*)&argv, NULL)) {
-
- /* ******************** USER BODY ******************** */
- if (((struct Library *)DOSBase)->lib_Version >= 39) {
- int i;
- retval = RETURN_OK;
- for (i = 0; argv.path[i] && !retval; ++i) {
- if (!SetOwner (argv.path[i], *argv.ownerid))
- retval = RETURN_ERROR;
- } /* for */
- } else
- SetIoErr(ERROR_INVALID_RESIDENT_LIBRARY);
- /* ******************** USER BODY ******************** */
- FreeArgs (args);
- } /* if */
-
- if (retval > RETURN_WARN)
- PrintFault(IoErr(), "SetOwner");
-
- CloseLibrary (DOSBase);
- } /* if */
- return (retval);
- } /* _main */
-
- /******************************************************************************
- ***** END SetOwner.c
- ******************************************************************************/
-
-